from django.shortcuts import render
from django.conf.urls import url
from rest_framework.routers import DefaultRouter
from rest_framework_jwt.views import obtain_jwt_token

from .views import users, sepecs, statistical, images, skus, orders, permission, groups, admin, options,channels,spus,brands

urlpatterns = [
    # 首页登录，返回token数据
    url(r'^authorizations/$', obtain_jwt_token),
    # 获取用户数量
    url(r'^statistical/total_count/$', statistical.UserToalCount.as_view()),
    # 获取日增用户
    url(r'^statistical/day_increment/$', statistical.UserDayCount.as_view()),
    # 获取日活跃用户
    url(r'^statistical/day_active/$', statistical.UserDayActiveCount.as_view()),
    # 获取下单用户
    url(r'^statistical/day_orders/$', statistical.UserDayOrdersCount.as_view()),
    # 月增用户统计
    url(r'^statistical/month_increment/$', statistical.UserMonthCOunt.as_view()),
    # 商品分类访问量统计
    url(r"^statistical/goods_day_views/$", statistical.GoodsTypeCount.as_view()),

    # 用户管理
    url(r'^users/$', users.UsersView.as_view()),
    # 规格管理
    url(r'^goods/simple/$', sepecs.SpecView.as_view({'get': 'simple'})),
    # 图片管理
    url(r'^skus/simple/$', images.ImageView.as_view({'get': 'simple'})),

    url(r'^goods/(?P<pk>\d+)/specs/$', skus.SKUView.as_view({'get': 'specs'})),
    # 获取权限管理
    url(r'^permission/content_types/$', permission.PermissionView.as_view({'get': 'content_types'})),
    # 用户组管理
    url(r'^permission/simple/$', groups.GroupsView.as_view({'get': 'simple'})),
    # 获取分组信息
    url(r'^permission/groups/simple/$', admin.AdminView.as_view({'get': 'groups'})),
    # 获取规格选项的规格
    url(r'^goods/specs/simple/$',options.SpecificationOptionView.as_view({'get': 'simple'})),
    # 商品频道
    url(r'^goods/channel_types/$',channels.GoodsChannelView.as_view({'get': 'simple'})),
    # 频道一级分类
    url(r'^goods/categories/$',channels.GoodsChannelView.as_view({'get': 'categories'})),
    # 获取品牌
    url(r'goods/brands/simple/$',spus.SPUView.as_view({'get':'brands'})),

    # spu表获取一级分类
    url(r'^goods/channel/categories/$',spus.SPUView.as_view({'get': 'categories'})),
    # spu表获取二级和三级分类
    url(r'^goods/channel/categories/(?P<pk>\d+)/$', spus.SPUView.as_view({'get': 'categories_child'})),
    # 获取图片
    url(r'^goods/images/$', spus.SPUView.as_view({'post': 'image'})),
]
# ------------------------------------------------------------------------------
# 规格管理   （增删查改）
# router  路由
router = DefaultRouter()
router.register('goods/specs', sepecs.SpecView, base_name='specs')
urlpatterns += router.urls

# 图片管理
router = DefaultRouter()
router.register('skus/images', images.ImageView, base_name='images')
urlpatterns += router.urls

# sku管理
router = DefaultRouter()
router.register('skus', skus.SKUView, base_name='skus')
urlpatterns += router.urls

# 订单表管理
router = DefaultRouter()
router.register('orders', orders.OrderInfoView, base_name='orders')
urlpatterns += router.urls

# 权限管理
router = DefaultRouter()
router.register('permission/perms', permission.PermissionView, base_name='perms')
# 分组表管理
router.register('permission/groups', groups.GroupsView, base_name='groups')
# 管理员管理
router.register('permission/admins', admin.AdminView, base_name='admins')
# 规格表选项管理
router.register('specs/options', options.SpecificationOptionView, base_name='options')
# 商品频道
router.register('goods/channels',channels.GoodsChannelView,base_name='channels')
# 商品品牌
router.register('goods/brands', brands.BrandChannelView, base_name='brands')
# spu表
router.register('goods',spus.SPUView,base_name='goods')
urlpatterns += router.urls
